using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEditor.Experimental.GraphView;
using UnityEngine;

public class TestPanel : EditorWindow
{
    public static int fontSize = 23;
    public static Font font;
    public static float floatValue;
    public static float num;
    public static Color _color;
    public static string str;
    public bool toggleOpen;
    public Vector2 _scrollPos;
    public AnimationCurve _animationCurve = new AnimationCurve();
    public static int gridId;
    public static string password = "";
    public static float sliderValue2;
    public static float sliderValue3;
    public static int layer;
    public static string tag;
    public static Object go;

    public static Bounds boundsv = new Bounds();
    public enum flagTestType
    {
        None,
        bbb,
        ccc,
        ddd,
        eee
    }
    public flagTestType flagtype;
    public flagTestType popupindex;
    public void OnGUI()
    {
        GUILayout.BeginVertical();
        
        GUILayout.BeginHorizontal();
        font = EditorGUILayout.ObjectField(font, typeof(Font), false) as Font;
        fontSize = EditorGUILayout.IntField(fontSize);
        GUILayout.EndHorizontal();
        
        EditorGUILayout.LabelField("计时: ",EditorApplication.timeSinceStartup.ToString());
        
        floatValue = EditorGUILayout.FloatField("浮点数", floatValue);

        num = EditorGUILayout.Slider ("Slider", num, -3, 3);
        //IntSlider
        EditorGUILayout.BeginFadeGroup(1f); // 组开始
        GUILayout.Button("Button0"); // 组中的内容，我这写了3个按钮
        GUILayout.Button("Button1");
        GUILayout.Button("Button2");
        EditorGUILayout.EndFadeGroup(); // 组结束

        toggleOpen = EditorGUILayout.BeginToggleGroup("Toggle", toggleOpen); // 组开始
        _color= EditorGUILayout.ColorField("Color", _color); // 组中的内容
        str = EditorGUILayout.TextField("Text", str);
        EditorGUILayout.EndToggleGroup();
        
        _scrollPos = EditorGUILayout.BeginScrollView(_scrollPos,GUILayout.MaxHeight(60)); // 组开始
        EditorGUILayout.LabelField("1212 12 312 1244124"); // 组中的内容
        EditorGUILayout.LabelField("123123123123123");
        EditorGUILayout.TextArea("12312312\n 3123123");
        EditorGUILayout.LabelField("123123123123123");
        EditorGUILayout.LabelField("123123123123123");
        EditorGUILayout.LabelField("123123123123123");
        EditorGUILayout.LabelField("123123123123123");
        EditorGUILayout.EndScrollView(); // 组结束
        
        _animationCurve = EditorGUILayout.CurveField("AnimationCurve", _animationCurve);
  
        gridId = GUILayout.SelectionGrid(gridId, new[] {"1", "2", "3","4","5","6"}, 3);
       
        GUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("密码：",GUILayout.Width(50));
        password = GUILayout.PasswordField(password, '*');
        GUILayout.EndHorizontal();
        
        EditorGUILayout.MinMaxSlider("MinMaxSlider",ref sliderValue2,ref sliderValue3,10,20);
        
        flagtype=(flagTestType)EditorGUILayout.EnumFlagsField(flagtype);
        
        popupindex=(flagTestType)EditorGUILayout.EnumPopup(popupindex);

        layer = EditorGUILayout.LayerField("LayerField", layer);
        tag = EditorGUILayout.TagField("TagField", tag);
        go = EditorGUILayout.ObjectField("ObjectField", go, typeof(GameObject), true);
        EditorGUILayout.Space();
        
        boundsv=EditorGUILayout.BoundsField("BoundsField",boundsv);

        //EditorGUILayout.PropertyField();
        
        index =EditorGUILayout.Popup(index, options);
        if(GUILayout.Button("Create"))
            InstantiatePrimitive();
        
        p1 =EditorGUILayout.Vector2Field("Point 1:", p1);
        
        GUILayout.EndVertical();
    }

    private Vector2 p1;
    
    string[] options ={"Cube","Sphere","Plane"};
    int index =0;

    void InstantiatePrimitive()
    {
        switch (index)
        {
                case 0:
                GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
                cube.transform.position = Vector3.zero;
                break;
                case 1:
                GameObject sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere);
                sphere.transform.position = Vector3.zero;
                break;
                case 2:
                GameObject plane = GameObject.CreatePrimitive(PrimitiveType.Plane);
                plane.transform.position = Vector3.zero;
                break;
            default:
                Debug.LogError("Unrecognized Option");
                break;
        }
    }

}
